<? 
$icon_size  = IPHONE_UI ? 64 : 48;
$icon_sab   = "/request/icon/button/video.download.png/caption/Download Video";
$icon_pic   = "/request/icon/button/image.16.png/caption/View Images";#"/images/video.download.png";
$ico = array ("m4v"=>"video.png",
               "rar"=>"rar.png",
               "wmv"=>"video.png",
               "picture"=>"image.png");
     
$key        = explode ('-', $this->item->id);
$css        = $this->manager->Find($this->group, $this->item->id) ? "font-weight:normal;color:black;" : ""; 
$targetURL  = $this->url( array(  
                                    "action"  => is_video($this->item->type) ? "view" : "gallery",
                                    "id"      => is_video($this->item->type) ? $key[0]: $this->item->id,
                                    "index"   => $this->item->index,
                                    "page"    => $this->page 
                                ) ); 
$icon       = $ico[$this->item->type];
$id         = "p.line.{$this->x}";
$im         = "p.preview.{$this->x}"; 
$ic         = "p.icon.{$this->x}"; 
$command    = array(); 
$sender     = $this->item->from['name'];# . ' &lt;' . $this->item->from['email'] . '&gt;';
$count      = sizeof($this->item->items);
$suffix     = IPHONE_UI ? "" : $count;
$stamp      = IPHONE_UI ? $count : $this->item->date;
$caption    = trunk($this->item->subject . ', ' . $suffix, TABLET_TEXT_LENGTH);
$parts      = sizeof(explode('-',$this->item->id));
$preview    = "";#$this->item->type;
$dot        = "<img align='absmiddle' src='/images/blueDot.gif' width='8' height='8' border='1'/>"; 
if ($this->item->image) {
    $css = "font-weight:normal;color:black"; 
}


switch ($this->item->type) {
    case "picture":
        $command[] = array( // 'text' => 'Click here to open',
                             'icon'=>$icon_pic,
                             'href' => $targetURL 
                       );
        $preview   = "<img align='left' src='/request/icon/arc/1,100/size/{$icon_size}' id='{$im}' height='{$icon_size}' border='1'/>";
        break;
    case "wmv": 
    case "m4v":
        if ($this->item->image) {
            $source    = "/request/picture/name/{$this->group}/image/{$this->item->index}"; 
            $preview   = "<img align='left' src='{$source}' height='{$icon_size}' border='1'/>";
            $command[] = array(// 'text'=>'Click here to view media',
                                'icon'=>$icon_sab ,
                                'href'=> $targetURL
                              );
        }
        else {
            $temp      = explode ('-', $this->item->id);
            $key       = $temp[0];
            $jump      = "javascript:LoadPageByPattern('%s','{$id}', '%s')";  
            $download  = "/tablet/group/sab/groupname/{$this->group}/index/{$this->item->index}/id/{$key}/page/{$this->page}";
            $href      =  sprintf($jump, $download, $targetURL ); 
            $command[] = array(// 'text'=>'Click here to download',
                                'icon'=>$icon_sab,
                                'href'=>$download); 
        }
        break;
    default:
}
/*
* BEGIN CONTENT ---------------------------------------------------------'
*/
?> 

<!-- begin line item -->
<p id="<?= $id ?>.panel"> 

  <!-- begin item link -->
  <a href="javascript:void(0)"
     style="<?= $css ?>"
     onclick="ServiceBus.OnItemClick (this, { id     : '<?= $id ?>', 
                                              target : '<?= $targetURL ?>', 
                                              key    : '<?= $this->item->id ?>', 
                                              group  : '<?= $this->group ?>', 
                                              index  : <?= $this->x ?> } )"
   >

    <!-- <?= $dot ?> -->

    <!-- item icon -->
    <img src="/images/<?= $icon ?>" id="<?= $this->item->id ?>" align="left" width="24" onload="LineItemAttach('<?= $id ?>', this)"/>

    <!-- item text -->
    <?= $sender ?>
    <br/>
    <label id="<?= $id ?>.label" style="font-weight:normal;font-size:9pt;padding:0px 0px 0px 2px;color:gray"><?= $caption ?></label>

    <!-- item arrow/count -->
    <span><span class="arrow"><?= $stamp ?> &#187;</span></span>

  </a>
  <!-- end item link -->
</p>

<!-- begin item menu -->
<p class="note" style="font-weight:normal;text-align:left;display:none;padding:2px 2px 4px 22px;" id="<?= $id ?>"
  <? if (is_video($this->item->type) && !$this->item->image):
     # including a title suppresses automatic onclick ?>
     title="Click to download" 
  <? endif ?>
>

  <!-- preview thumbnail -->
  <?= $preview ?>

  <!-- item full text -->
  <strong><?= $this->item->subject ?></strong>
  <br/> 

  <!-- item counts -->
  <?= $count ?> article<?= plural($count) ?>, <?= $parts ?> part<?= plural($parts) ?>
  <br/>

  <!-- item commands -->
  <? foreach ($command as $i): ?>

    <a href="<?= $i['href'] ?>">

    <? if ($i['icon']): ?>
      <img src="<?= $i['icon'] ?>" align="absmiddle" border="0"/>
    <? endif ?>

    <?= $i['text'] ?></a>

  <?php endforeach ?>  

  <?= $previewr ?>
</p>
<!-- end item menu -->

<!-- end line item -->




